﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace LotteCinema
{
    public partial class ThemGhe : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["y"] != null && Request["x"] != null && Request["checked"] != null)
                if (bool.Parse(Request["checked"].ToString()))
                {
                    string maghe = CProvider.LayDuLieu("select mag from ghe where sohang='" + Request["y"].ToString() + "' and soday='" + Request["x"].ToString() + "' and maphong='" + Session["maphong"].ToString() + "'");
                    DataTable dtVeDaDat = (DataTable)Session["VeDaDat"];
                    dtVeDaDat.Rows.Add(maghe, Session["matv"].ToString(), Session["malcp"].ToString(), Session["masc"].ToString());
                    Session["VeDaDat"] = dtVeDaDat;
                    Response.Write("");
                }
                else
                {
                    string maghe = CProvider.LayDuLieu("select mag from ghe where sohang='" + Request["y"].ToString() + "' and soday='" + Request["x"].ToString() + "' and maphong='" + Session["maphong"].ToString() + "'");
                    DataTable dtVeDaDat = (DataTable)Session["VeDaDat"];
                    for (int i = 0; i < dtVeDaDat.Rows.Count; i++)
                        if (dtVeDaDat.Rows[i][0].ToString() == maghe)
                        {
                            dtVeDaDat.Rows.Remove(dtVeDaDat.Rows[i]);
                            break;
                        }
                    Session["VeDaDat"] = dtVeDaDat;
                    Response.Write("");
                }
        }
    }
}